package com.joven.shelltest.utils.customretry;

/**
 * @Author: wzj
 * @Date: 2024/3/26 14:54
 */
public class RetryTest {

    public static void main(String[] args) {
        //最大重试次数
        int maxRetryCount = 3;
        Object result = RetryExecutor.execute(maxRetryCount, new ReBack() {
            @Override
            public RetryResult doProcess(int num) {
                num++;
                // 执行需要重试的逻辑
                if (num < 10) {
                    // 如果需要重试，返回 RetryResult.ofResult(true)
                    return RetryResult.ofResult(true);
                } else {
                    // 如果不需要重试，返回 RetryResult.ofResult(false, result)
                    return RetryResult.ofResult(false, "num is greater than 10");
                }
            }
        }, 10);
        System.out.println(result);
    }
}
